page.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { Suspense } from "react";
  2. import { notFound } from "next/navigation";
  3. import { getLayoutConfiguration } from "@/app/actions/layout-configurations";
  4. import { LayoutConfigurationDetail } from "@/app/components/layout-configurations/LayoutConfigurationDetail";
  5. import { Skeleton } from "@/components/ui/skeleton";
  6. interface PageProps {
  7. params: {
  8. id: string;
  9. };
  10. }
  11. export default async function LayoutConfigurationDetailPage({ params }: PageProps) {
  12. const p = await params;
  13. const id = parseInt(p.id);
  14. if (isNaN(id)) {
  15. notFound();
  16. }
  17. const result = await getLayoutConfiguration(id);
  18. if (!result.success || !result.data) {
  19. notFound();
  20. }
  21. const configuration = result.data;
  22. return (
  23. <div className="container mx-auto py-8 px-4">
  24. <div className="mb-6">
  25. <h1 className="text-3xl font-bold">{configuration.name}</h1>
  26. <p className="text-muted-foreground">
  27. Created: {new Date(configuration.createdAt).toLocaleDateString()}
  28. </p>
  29. </div>
  30. <Suspense fallback={<LayoutConfigurationDetailSkeleton />}>
  31. <LayoutConfigurationDetail configuration={configuration} />
  32. </Suspense>
  33. </div>
  34. );
  35. }
  36. function LayoutConfigurationDetailSkeleton() {
  37. return (
  38. <div className="space-y-6">
  39. <Skeleton className="h-8 w-64" />
  40. <Skeleton className="h-4 w-32" />
  41. <Skeleton className="h-32 w-full" />
  42. </div>
  43. );
  44. }